﻿namespace DomainServices.Tools
{
    using System;
    using System.Collections.Generic;

    internal class CodeGenerationHost : ICodeGenerationHost, ILogger
    {
        private ILoggingService _loggingService;
        private ISharedCodeService _sharedCodeService;

        internal CodeGenerationHost(ILoggingService loggingService, ISharedCodeService sharedCodeService)
        {
            this._loggingService = loggingService;
            this._sharedCodeService = sharedCodeService;
        }

        public CodeMemberShareKind GetMethodShareKind(string typeName, string methodName, IEnumerable<string> parameterTypeNames)
        {
            return this.SharedCodeService.GetMethodShareKind(typeName, methodName, parameterTypeNames);
        }

        public CodeMemberShareKind GetPropertyShareKind(string typeName, string propertyName)
        {
            return this.SharedCodeService.GetPropertyShareKind(typeName, propertyName);
        }

        public CodeMemberShareKind GetTypeShareKind(string typeName)
        {
            return this.SharedCodeService.GetTypeShareKind(typeName);
        }

        public void LogError(string message)
        {
            this.LoggingService.LogError(message);
        }

        public void LogError(string message, string subcategory, string errorCode, string helpKeyword, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber)
        {
            this.LoggingService.LogError(message, subcategory, errorCode, helpKeyword, file, lineNumber, columnNumber, endLineNumber, endColumnNumber);
        }

        public void LogMessage(string message)
        {
            this.LoggingService.LogMessage(message);
        }

        public void LogWarning(string message)
        {
            this.LoggingService.LogWarning(message);
        }

        public void LogWarning(string message, string subcategory, string errorCode, string helpKeyword, string file, int lineNumber, int columnNumber, int endLineNumber, int endColumnNumber)
        {
            this.LoggingService.LogWarning(message, subcategory, errorCode, helpKeyword, file, lineNumber, columnNumber, endLineNumber, endColumnNumber);
        }

        public bool HasLoggedErrors
        {
            get
            {
                return this.LoggingService.HasLoggedErrors;
            }
        }

        private ILoggingService LoggingService
        {
            get
            {
                return this._loggingService;
            }
        }

        private ISharedCodeService SharedCodeService
        {
            get
            {
                return this._sharedCodeService;
            }
        }
    }
}

